package com.gitee.cashzhang27.test.cloud.oauth.auth.server.extended.handler;


import com.gitee.cashzhang27.test.cloud.oauth.auth.server.extended.entity.UserDetails;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;

/**
 * @author Cash Zhang
 * @version v1.0
 * @since 2019/02/01 11:45
 */
@Slf4j
@Component
public class AuthenticationSuccessEventHandler extends AbstractAuthenticationSuccessEventHandler {

  /**
   * 处理登录成功方法
   * <p>
   * 获取到登录的authentication 对象
   *
   * @param authentication 登录对象
   */
  @Override
  public void handle(Authentication authentication) {
    UserDetails userDetailsVO = (UserDetails) authentication.getPrincipal();
    log.info("用户：{} 登录成功", userDetailsVO.getId());
  }
}
